package com.airlines.crewassignment.domain.util;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.airlines.crewassignment.domain.Crew;
import com.airlines.crewassignment.domain.CrewFlightExperienceAcType;

/**
 * @author xxxx
 * @date 2018年7月19日 
 * @description 飞行员经历时间方法类
 */
public class SeatDurationUtil {

	/**
	 * 查询某个飞行员某个机型的所有经历时间
	 * @param crew
	 *  @param acType 可以为null
	 * @param day 可以为null
	 * @return
	 */
	public static int getSeatDuration(Crew crew,String acType){
		List<CrewFlightExperienceAcType> cfeaList = crew.getCrewFlightExperience().getCfeAcTypeList();
		for(CrewFlightExperienceAcType cfea : cfeaList){
			if(StringUtils.equals(acType, cfea.getAcType())){
				return cfea.getSeatDuration();
			}
		}
		return 0;
	}
	
	/**
	 * 获取某个机型的近90天的经历
	 * @param crew
	 * @param acType
	 * @return
	 */
	public static int getSeatDurationLast90Days(Crew crew,String acType){
		List<CrewFlightExperienceAcType> cfeaList = crew.getCrewFlightExperience().getCfeAcTypeList();
		for(CrewFlightExperienceAcType cfea : cfeaList){
			if(StringUtils.equals(acType, cfea.getAcType())){
				return cfea.getSeatDurationLast90Days();
			}
		}
		return 0;
	}

}
